def checkValidString(s: str) -> bool:
    left_brackets = []
    stars = []

    for index, char in enumerate(s):
        if char == '(':
            left_brackets.append(index)
            continue

        if char == '*':
            stars.append(index)
            continue

        if char == ')':
            if left_brackets:
                left_brackets.pop()
                continue
            if stars:
                stars.pop()
                continue
            return False

    while left_brackets and stars:
        bracket_index = left_brackets.pop()
        star_index = stars.pop()
        if bracket_index > star_index:
            return False

    return len(left_brackets) == 0
